package agent;

import labyrinth.Map;
import agent.moves.DirectionMove;
import agent.moves.IAgentMove;
import agent.moves.InvalidDirectionException;
/**
 * A very simple agent which does random moves in the labyrinth
 * 
 * @author Johannes Kulick
 * @version 0.1
 * @licence GNU Lesser General Public License
 */
public class SimpleAgent extends IAgent {

	private int mDirection = 0;
	
	private boolean plus = true;
	@Override
	public IAgentMove getNextMove(Map position, IAgentMove move) {
		if(move == null)
		{
			if(plus) {
				mDirection++;
				if(mDirection == 3)
					plus = false;
			}
			else {
				mDirection--;
				if(mDirection == 0)
					plus = true;
			}
		}
		try {
			return new DirectionMove(mDirection);
		} catch (InvalidDirectionException e) {
			e.printStackTrace();
			return null;
		} 
	}

}
